import "./moi.js";
import "./currency.js";
import "./number.js";
import "./global.js";
import "./waterfalls.js";
import "./lazyImgs.js";

//商品列表图片比例
function imgSize(productBox) {
    // const productBox = $(classID);
    for (let i = 0; i < productBox.length; i++) {
        var self = productBox.eq(i);

        var data_scale = self.data("scale").toString();
        var productWidth = parseInt(self.width());
        if (data_scale === "none" || !productWidth) {
            return false;
        }

        switch (data_scale) {
            case "11":
                self.css("height", productWidth);
                break;
            case "34":
                self.css("height", (productWidth / 3) * 4);
                break;
            case "23":
                self.css("height", (productWidth / 2) * 3);
                break;
            case "12":
                self.css("height", (productWidth / 1) * 2);
                break;
            default:
                break;
        }

        self.attr("data-scale", "none");
    }
}
$(window).resize(function () {
    imgSize($(".product_img"));
});

$(window).load(function () {
    imgSize($(".product_img"));
});
imgSize($(".product_img"));

window.productSize = imgSize;

$("img").error(function () {
    $(this).attr("src", "/theme/default/assets/empty.png");
});
